package org.vz.product.vserv.amq.web;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.vz.product.vserv.amq.domain.ActivemqHost;
import org.vz.product.vserv.amq.service.AcqclusterService;
import org.vz.product.vserv.amq.utils.StringUtil;

@Controller
@RequestMapping("/amq")
public class AMQOfBus {
	@Autowired
	AcqclusterService acqclusterService;
	
	@RequestMapping("/bus")
	@ResponseBody
	public String bus(@RequestParam(value = "userName", defaultValue = "") String words){
		List<ActivemqHost> list = acqclusterService.currentState();
		Map<String,List<ActivemqHost>> lisMap = new HashMap<String, List<ActivemqHost>>();
		lisMap.put("clusterMetrics", list);
		Map<String,Object> rlt =new HashMap<String, Object>();
		if(list != null){
			rlt.put("status", "1");
			rlt.put("msg", "查询成功");
		}else{
			rlt.put("status", "-1");
			rlt.put("msg", "查询失败");
		}
		
		rlt.put("data", lisMap);
		return StringUtil.toJsonString(rlt);
	}
}
